namespace :trifle do
  desc "Install a default config/trifle-ruby.yml file"
  task :install do
    puts "This will configure config/trifle-ruby.yml file. Any existing file will be replaced."

    puts "Enter Application API KEY:"
    api_key = STDIN.gets.strip

    config = {
      "production" => {
        "api_key" => api_key,
        "rails" => {
          "enabled" => true
        },
        "sidekiq" => {
          "enabled" => true
        }
      }
    }

    puts "Here is your configuration."
    puts config.to_yaml
    path = File.join("config", "trifle-ruby.yml")
    File.open(path, "wb") { |f| f.write(config.to_yaml) }

    puts "You will find it saved at config/trifle-ruby.yml. Please validate your config and change it if it's necessary."
  end
end
